package com.bwie.groupon.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.groupon.entity.GrouponDescEntity;
import com.bwie.groupon.service.GrouponDescService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 
 *
 * @author wangguohai
 * @email 270901876@qq.com
 * @date 2022-04-26 19:40:22
 */
@RestController
@RequestMapping("groupon/groupondesc")
public class GrouponDescController {
    @Autowired
    private GrouponDescService grouponDescService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = grouponDescService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{grouponDescId}")
    public R info(@PathVariable("grouponDescId") Integer grouponDescId){
        GrouponDescEntity grouponDesc = grouponDescService.getById(grouponDescId);

        return R.ok().put("grouponDesc", grouponDesc);
    }


    @RequestMapping("/getuid/{userId}")
    public R getuid(@PathVariable("userId") Integer userId){
        GrouponDescEntity grouponDesc = grouponDescService.getuserId(userId);

        return R.ok().put("grouponDesc", grouponDesc);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody GrouponDescEntity grouponDesc){
		grouponDescService.save(grouponDesc);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody GrouponDescEntity grouponDesc){
		grouponDescService.updateById(grouponDesc);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] grouponDescIds){
		grouponDescService.removeByIds(Arrays.asList(grouponDescIds));

        return R.ok();
    }

}
